home *** CD-ROM | disk | FTP | other *** search
/ Champak 123 / (Vol 123) Jan 13 2011.iso / Games / mofro.swf / scripts / frame_1 / DoAction_3.as < prev    next >
Encoding:
Text File  |  2011-01-13  |  9.3 KB  |  425 lines

  1. function pickup(newname)
  2. {
  3.    currentitem[4] = items[newname][0];
  4.    currentitem[5] = items[newname][1];
  5.    currentitem[6] = items[newname][2];
  6.    currentitem[7] = items[newname][3];
  7.    if(currentitem[1] != false)
  8.    {
  9.       items[newname][0] = currentitem[0];
  10.       items[newname][1] = currentitem[1];
  11.       items[newname][2] = currentitem[2];
  12.       items[newname][3] = currentitem[3];
  13.       _root["item" + newname].attachMovie(items[newname][1],"inside",1);
  14.    }
  15.    else
  16.    {
  17.       _root.score += 1;
  18.       items[newname][0] = false;
  19.       items[newname][1] = false;
  20.       items[newname][2] = false;
  21.       items[newname][3] = false;
  22.       _root["item" + newname].inside.removeMovieClip();
  23.    }
  24.    currentitem.shift();
  25.    currentitem.shift();
  26.    currentitem.shift();
  27.    currentitem.shift();
  28.    item = "carrying " + _root.currentitem[0];
  29. }
  30. function endcheck()
  31. {
  32.    if(reallife <= 0)
  33.    {
  34.       life = 0;
  35.       if(canmove)
  36.       {
  37.          hero.gotoAndStop("death");
  38.          _root.canmove = false;
  39.       }
  40.    }
  41. }
  42. function saveinit()
  43. {
  44.    first = true;
  45.    phonechance = true;
  46.    hero._visible = 1;
  47.    life = Math.round(reallife);
  48. }
  49. function init()
  50. {
  51.    initarrays();
  52.    ememies = 0;
  53.    phatnum = 0;
  54.    doornum = 0;
  55.    canmove = true;
  56.    scene = 1;
  57.    herocolor = new Color(hero);
  58.    hero.high = 65;
  59.    distance = - dis;
  60.    getUrl("FSCommand:allowscale", "false");
  61.    getUrl("FSCommand:fullscreen", "true");
  62.    currentitem = new Array();
  63.    removeitem();
  64.    item = "carrying " + _root.currentitem[0];
  65.    reallife = 100;
  66.    score = 0;
  67.    stageleft = 8;
  68.    stageright = 660;
  69.    stagetop = 49;
  70.    stagebottom = 437;
  71.    hero.h_width = 12;
  72.    downspeed = 1;
  73.    originalupspeed = 20;
  74.    upspeed = originalupspeed;
  75.    gravity = 2;
  76.    speed = 4;
  77.    saveinit();
  78. }
  79. function scenechange(doornum)
  80. {
  81.    newdoor = doors[doornum][1];
  82.    distance = doors[doornum][2];
  83.    gotoAndPlay(doors[doornum][0]);
  84. }
  85. function remove_swarm()
  86. {
  87.    if(swarmarray[scene][0] == "alien")
  88.    {
  89.       alien.removeMovieClip();
  90.    }
  91.    else
  92.    {
  93.       sw = 2;
  94.       while(sw >= 0)
  95.       {
  96.          _root["swarm" + sw].removeMovieClip();
  97.          sw--;
  98.       }
  99.    }
  100. }
  101. function removeitem()
  102. {
  103.    currentitem[0] = "nothing";
  104.    currentitem[1] = false;
  105.    currentitem[2] = false;
  106.    currentitem[3] = false;
  107.    item = "carrying " + _root.currentitem[0];
  108. }
  109. function initscene()
  110. {
  111.    phatman1.removeMovieClip();
  112.    if(swarmarray[scene][0] == "alien")
  113.    {
  114.       if(swarmarray[scene][3] == "prof")
  115.       {
  116.          _root.attachMovie("professor","alien",200 + s);
  117.       }
  118.       else
  119.       {
  120.          _root.attachMovie("alien","alien",200 + s);
  121.       }
  122.       _root.alien._xscale = 100;
  123.       _root.alien._yscale = 100;
  124.       _root.alien._x = _root.swarmarray[scene][1];
  125.       _root.alien._y = _root.swarmarray[scene][2];
  126.    }
  127.    else
  128.    {
  129.       top = swarmarray[scene][0];
  130.       top = checknumber(top);
  131.       s = top;
  132.       while(s > 0)
  133.       {
  134.          _root.attachMovie("swarmer","swarm" + s,200 + s);
  135.          _root["swarm" + s]._x = _root.swarmarray[scene][1];
  136.          _root["swarm" + s]._y = _root.swarmarray[scene][2];
  137.          s--;
  138.       }
  139.    }
  140.    if(first)
  141.    {
  142.       delete first;
  143.       if(saved)
  144.       {
  145.          hero._x = _root["asavephone" + phonenumber]._x;
  146.          hero._y = _root["asavephone" + phonenumber]._y;
  147.          delete saved;
  148.       }
  149.       else
  150.       {
  151.          hero._x = 350;
  152.          hero._y = 10;
  153.       }
  154.    }
  155.    else
  156.    {
  157.       hero._x = _root["door" + newdoor]._x + distance;
  158.       hero._y = _root["door" + newdoor]._y - 10;
  159.    }
  160.    hero.x = hero._x;
  161.    place = "you are " + sceneword[scene];
  162.    updoing = false;
  163.    maxwall = 1;
  164. }
  165. function findvariables(name)
  166. {
  167.    _root[name].miny = Math.round(_root[name]._y - _root[name]._height / 2);
  168.    _root[name].maxy = Math.round(_root[name]._y + _root[name]._height / 2);
  169.    _root[name].minx = Math.round(_root[name]._x - _root[name]._width / 2);
  170.    _root[name].maxx = Math.round(_root[name]._x + _root[name]._width / 2);
  171. }
  172. function walk()
  173. {
  174.    if(runtime > 20)
  175.    {
  176.       if(downmove)
  177.       {
  178.          speed = 6;
  179.       }
  180.       else
  181.       {
  182.          speed = 7;
  183.       }
  184.    }
  185.    else
  186.    {
  187.       speed = 4;
  188.    }
  189.    maptest("hero");
  190.    if(Key.isDown(32))
  191.    {
  192.       if(notfired && currentitem[2])
  193.       {
  194.          fire_weapon();
  195.          notfired = false;
  196.       }
  197.    }
  198.    else
  199.    {
  200.       notfired = true;
  201.    }
  202.    if(canmove)
  203.    {
  204.       if(Key.isDown(37))
  205.       {
  206.          runtime++;
  207.          if(speed == 4)
  208.          {
  209.             hero.frame = "run";
  210.          }
  211.          else
  212.          {
  213.             hero.frame = "fastrun";
  214.          }
  215.          hero.x -= speed;
  216.          hero._xscale = -50;
  217.       }
  218.       else if(Key.isDown(39))
  219.       {
  220.          runtime++;
  221.          if(speed == 4)
  222.          {
  223.             hero.frame = "run";
  224.          }
  225.          else
  226.          {
  227.             hero.frame = "fastrun";
  228.          }
  229.          hero.x += speed;
  230.          hero._xscale = 50;
  231.       }
  232.       else
  233.       {
  234.          runtime = 0;
  235.          hero.frame = "stand";
  236.       }
  237.    }
  238.    if(hero.miny > hero._y)
  239.    {
  240.       downmove = true;
  241.    }
  242.    else
  243.    {
  244.       downmove = false;
  245.    }
  246.    hero.y = hero._y;
  247.    if((Key.isDown(38) && downmove == false || Key.isDown(38) && updoing) && canmove)
  248.    {
  249.       moveup();
  250.       hero.frame = "jumping";
  251.    }
  252.    else if(downmove)
  253.    {
  254.       hero.frame = "landing";
  255.       movedown();
  256.    }
  257.    else
  258.    {
  259.       upspeed = originalupspeed;
  260.    }
  261.    if(hero.x < hero.minx)
  262.    {
  263.       hero.x = hero.minx;
  264.       if(hero.frame == "run" || hero.frame == "fastrun")
  265.       {
  266.          hero.frame = "stand";
  267.       }
  268.    }
  269.    else if(hero.x > hero.maxx)
  270.    {
  271.       hero.x = hero.maxx;
  272.       if(hero.frame == "run" || hero.frame == "fastrun")
  273.       {
  274.          hero.frame = "stand";
  275.       }
  276.    }
  277.    hero._y = hero.y;
  278.    if(canmove)
  279.    {
  280.       hero.x += hero.xchange;
  281.       hero.xchange = 0;
  282.       hero._x = hero.x;
  283.       hero.gotoAndStop(hero.frame);
  284.    }
  285. }
  286. function moveup()
  287. {
  288.    updoing = true;
  289.    downspeed = 1;
  290.    hero.y -= upspeed;
  291.    upspeed -= gravity;
  292.    if(upspeed < 1)
  293.    {
  294.       updoing = false;
  295.       upspeed = originalupspeed;
  296.    }
  297.    else if(hero.y < hero.maxy)
  298.    {
  299.       hero.y = hero.maxy;
  300.       updoing = false;
  301.       upspeed = originalupspeed;
  302.    }
  303. }
  304. function movedown()
  305. {
  306.    updoing = false;
  307.    hero.y += downspeed;
  308.    downspeed += gravity;
  309.    if(hero.y >= hero.miny)
  310.    {
  311.       hero.frame = "landed";
  312.       hero.y = hero.miny;
  313.       downspeed = 1;
  314.       upspeed = originalupspeed;
  315.    }
  316. }
  317. function maptest(name)
  318. {
  319.    _root[name].miny = stagebottom;
  320.    _root[name].maxy = stagetop;
  321.    _root[name].minx = stageleft;
  322.    _root[name].maxx = stageright;
  323.    top = maxwall + 1;
  324.    top = checknumber(top);
  325.    i = 1;
  326.    while(i < top)
  327.    {
  328.       if(_root[name]._x + _root[name].h_width / 2 > _root["wall" + i].minx && _root[name]._x - _root[name].h_width / 2 < _root["wall" + i].maxx)
  329.       {
  330.          if(_root[name]._y <= _root["wall" + i].miny && _root["wall" + i].miny < _root[name].miny)
  331.          {
  332.             _root[name].miny = _root["wall" + i].miny;
  333.          }
  334.          else if(_root[name]._y - _root[name].high >= _root["wall" + i].maxy && _root["wall" + i].maxy > _root[name].maxy)
  335.          {
  336.             _root[name].maxy = _root["wall" + i].maxy + _root[name].high;
  337.          }
  338.       }
  339.       if(_root[name]._y > _root["wall" + i].miny && _root[name]._y - _root[name].high < _root["wall" + i].maxy)
  340.       {
  341.          if(_root[name]._x <= _root["wall" + i]._x && _root["wall" + i].minx < _root[name].maxx)
  342.          {
  343.             _root[name].maxx = _root["wall" + i].minx - _root[name].h_width;
  344.          }
  345.          else if(_root[name]._x >= _root["wall" + i]._x && _root["wall" + i].maxx > _root[name].minx)
  346.          {
  347.             _root[name].minx = _root["wall" + i].maxx + _root[name].h_width;
  348.          }
  349.       }
  350.       i++;
  351.    }
  352. }
  353. function checknumber(name)
  354. {
  355.    if(name < 100)
  356.    {
  357.       return name;
  358.    }
  359.    return 3;
  360. }
  361. getUrl("FSCommand:showmenu", "false");
  362. initphatmen22 = function()
  363. {
  364.    i = 1;
  365.    while(i <= phatnum)
  366.    {
  367.       _root["p" + i]._visible = 1;
  368.       i++;
  369.    }
  370.    i = phatnum + 1;
  371.    while(i <= 5)
  372.    {
  373.       _root["p" + i]._visible = 0;
  374.       i++;
  375.    }
  376.    if(phatnum == 5)
  377.    {
  378.       doors[122][3] = false;
  379.    }
  380. };
  381. fire_weapon = function()
  382. {
  383.    bulletnum = currentitem[3];
  384.    if(bulletnum < 3)
  385.    {
  386.       d = 1;
  387.       while(d <= 3)
  388.       {
  389.          _root.attachMovie("bullet","bullet" + d,d);
  390.          _root["bullet" + d]._x = hero._x;
  391.          _root["bullet" + d]._y = hero._y - 40;
  392.          d++;
  393.       }
  394.       if(bulletnum == 1)
  395.       {
  396.          bulletnum = 1;
  397.          bullet1.x = -1;
  398.          bullet1.y = 0;
  399.          bullet2.x = 0;
  400.          bullet2.y = -1;
  401.          bullet3.x = 1;
  402.          bullet3.y = 0;
  403.       }
  404.       else if(bulletnum == 2)
  405.       {
  406.          bulletnum = 2;
  407.          bullet1.x = -0.5;
  408.          bullet1.y = 0.5;
  409.          bullet2.x = 0.5;
  410.          bullet2.y = -0.5;
  411.          bullet3.x = 0.5;
  412.          bullet3.y = 0.5;
  413.       }
  414.    }
  415.    else
  416.    {
  417.       d = 1;
  418.       _root.attachMovie("bullet","bullet" + d,d);
  419.       _root["bullet" + d]._x = hero._x;
  420.       _root["bullet" + d]._y = hero._y - 40;
  421.    }
  422.    removeitem();
  423. };
  424. init();
  425.